<?php
include_once('admin-load.php');
	$user_id = $_REQUEST['user_id'];
     if ($user_id) {
            
            $user = $dbna->get_row("SELECT * FROM users WHERE id = $user_id ");
            
     }

    if (isset($_POST['submit_form'])) {
        update_user();
    }
?> 
<?php
	include_once 'header.php';
?>
            <div id="main_content">
                            <div id="content">
                    
		</div>
        <div class="container">
            <h5>Edit User</h5>

        </div>
				<div id="main">
                    <h2>Edit User</h2>
                    <form id="add_user" action="user-edit.php?user_id=<?php echo $user_id ?>" method="post">
                        <input type="hidden" value="<?php echo $user_id ?>" name="user_id"/>
                        <input type="hidden" value="1" name="submit_form"/>
                        <fieldset>
                            <legend>Edit User</legend>
                        <div>
                            <label for="username">Username : </label>
                            <input type="text" id="username" value="<?php echo $user->username ?>" readonly/>
                        </div>
                        <div>
                            <label for="password">Password : </label>
                            <input type="password" id="password" name="password"/>
                        </div>
                        <div>
                            <label for="newpwd">Password Confirm : </label>
                            <input type="password" id="newpwd" name="newpwd"/>
                        </div>
                        <div>
                            <label for="email">Email : </label>
                            <input type="text" id="email" name="email" value="<?php echo $user->email ?>"/>
                        </div>
                        <div>
                            <label for="firstname">First name : </label>
                            <input type="text" id="firstname" name="firstname" value="<?php echo $user->firstname ?>"/>
                        </div>
                        <div>
                            <label for="lastname">Last name : </label>
                            <input type="text" id="lastname" name="lastname" value="<?php echo $user->lastname ?>"/>
                        </div>
                            <div>
                                <label for="groups">Group : </label>
                                    <?php echo groupSelect($user->group_id); ?>
                            </div>
                        <div class="buttons">
                            <input type="submit" value="Update" name="submit"/>   
                        </div>
                    </form>
                </div>
            </div>
  <?php 
	include_once 'footer.php';
?>